package ypmits.unittest {
	import ypmits.setup.EasySetup;
	import ypmits.setup.EasySetupInput;
	import ypmits.setup.view.FullScreenButtonGraphic;

	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.events.Event;
	import flash.geom.Point;

	/**
	 * @author Dave Lenz
	 */
	public class BaseTest extends Sprite {
		
		protected var sw : Number;
		protected var sh : Number;
		protected var base_ball : Sprite;
		protected var base_square : Sprite;
		protected var rand : Boolean;
		
		public function BaseTest( fscolor : uint = 0, debug : Boolean = true, rand : Boolean = false ) {
			this.rand = rand;
			
			var i : EasySetupInput = new EasySetupInput( );
			i.fullscreenbuttongraphic = new FullScreenButtonGraphic( 15, 15, fscolor, stage, StageAlign.BOTTOM_LEFT );
			i.fullscreenoffset = new Point( 5, 5 );
			
			setStageSizes();
			
			EasySetup.instance.init( this, i );
			EasySetup.instance.debug = debug;
			EasySetup.instance.stage.addEventListener(Event.RESIZE, resizeHandler );
			
			if( rand ) drawRand( );
			
			base_ball = new Sprite();
			base_square = new Sprite();
		}

		
		private function drawRand() : void {
			graphics.clear();
			graphics.beginFill( 0 );
			graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight );
			graphics.drawRect(1, 1, stage.stageWidth - 2, stage.stageHeight - 2 );
			graphics.endFill();
		}

		
		protected function resizeHandler( e : Event) : void {
			setStageSizes();
			if( rand ) drawRand();
		}
		
		
		private function setStageSizes() : void {
			sw = stage.stageWidth;
			sh = stage.stageHeight;
		}
	}
}
